/*
 * @Author: czy
 * @Date: 2021-07-09 09:29:04
 * @LastEditTime: 2021-07-12 22:11:28
 */
#include "sys/container.h"

#include "../lib/io.h"
#include "../lib/uart.h"
#include "../lib/input.h"

Deque buffer = newDeque(char, 100);

/**
 * @description: Check the input port at intervals and send the input characters into the input buffer.
 */
void check_input_port(void)
{
    if ((inb(uart_flag) & 1))
    {
        char ch = inb(uart_base);
        buffer.frpush(&buffer, ch);
    }
}

/**
 * @description: Get a character from the uart. 
 * @return Character entered.
 */
unsigned char uart_get_char(void)
{
    while (buffer.empty(&buffer))
        ;
    char ch;
    buffer.lpop(&buffer, &ch);
    return ch;
}
